package com.jfinal.j2cache.plugin.j2cache;

import com.jfinal.j2cache.CacheFactory;
import com.jfinal.j2cache.impl.j2cache.J2CacheManager;
import com.jfinal.plugin.IPlugin;
import net.oschina.j2cache.CacheChannel;
import net.oschina.j2cache.J2Cache;

public class J2CachePlugin implements IPlugin {

    private static CacheChannel cache;

    @Override
    public boolean start() {
        System.setProperty("java.net.preferIPv4Stack", "true"); //Disable IPv6 in JVM
        cache = J2Cache.getChannel();
        J2CacheKit.init(cache);
        CacheFactory.setCacheManager(new J2CacheManager());
        return true;
    }

    @Override
    public boolean stop() {
        cache.close();
        return true;
    }
}
